/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

/**
 *
 * @author Dhruv
 */
//class for displaying image when thumbnail is clicked
class DisplayThumb extends AbstractAction
{
	//the below JFrame is assigned in the constructor
	private JFrame frame;
	//the below JLabel is assigned in the constructor
	private JLabel photographLabel;
	//the image we want to display when thumbnail is clicked
	private ImageIcon displayPhoto;

	//class constructor
	public DisplayThumb(ImageIcon photo, ImageIcon thumb, String desc, JLabel lab, JFrame fra)
	{
		//assign the full size photo to displayPhoto
		displayPhoto = photo;
		//description of the thumbnail tooltip
		putValue(SHORT_DESCRIPTION, desc);
		//sets the ImageIcon thumb as the thumbnail
		putValue(LARGE_ICON_KEY, thumb);
		//assign the JLabel lab to photographLabel
		photographLabel = lab;
		//assign the JFrame fra to frame
		frame = fra;
	}//end constructor

	//action event on listeners triggers this method
	public void actionPerformed(ActionEvent e)
	{
		//the ImageIcon displayPhoto is displayed in the JLabel
		photographLabel.setIcon(displayPhoto);
		//set the title of the frame
		frame.setTitle("Icon Demo: " + getValue(SHORT_DESCRIPTION).toString());
	}//end method
}//end class